package com.msl.base.controller;

import entity.Result;
import entity.StatusCode;
import org.springframework.web.bind.annotation.ControllerAdvice;
import org.springframework.web.bind.annotation.ExceptionHandler;
import org.springframework.web.bind.annotation.ResponseBody;

/**
 * @ProjectName: tensquare_parent03
 * @Package: com.msl.base.controller
 * @ClassName: ExcetionController
 * @Author: Messi
 * @Date: 2020/7/30 21:44
 * @Version: 1.0
 */
@ControllerAdvice
public class ExcetionController {//为了项目遇到异常统一返回风格，建立这个类处理异常
    @ExceptionHandler(value = Exception.class)
    @ResponseBody
    public Result handExcetion(Exception e){
        e.printStackTrace();
        return new Result(false, StatusCode.ERROR,e.getMessage());
    }
}
